home *** CD-ROM | disk | FTP | other *** search
- title BCB.ASM Finds Concurrent PC-DOS disk buffers & control blocks
-
- dos equ 33 ; PC-DOS entry point
- wrt_dev equ 40h ; write to device
- ccpm equ 224 ; Concurrent entry point
- s_sysdat equ 9Ah ; get system data segment
-
- std_out equ 1 ; standard output file handle
-
- dph equ 0C18h ; offset of dph table in sysdat
- dpb equ 8 ; offset of dpb in dph
- dirbcb equ 0Eh ; offset of dirbcb in dph
- datbcb equ 10h ; offset of datbcb in dph
- bcblr equ 0 ; offset of bcb link list root bcbh
- mbcbp equ 2 ; offset of max bcb per process in bcbh
- bufad equ 0Ah ; offset of ptr to buffer in bcb
- link equ 0Ch ; offset of ptr to nxt bcb in bcb
-
- cr equ 0Dh
- lf equ 0Ah
-
- wpt equ word ptr
- bpt equ byte ptr
- jmps macro x
- jmp short
- endm
-
- int_tab SEGMENT AT 0
- ORG ccpm*4
- ccpm_entry dw ?
-
- int_tab ENDS
-
- cseg SEGMENT word public 'CODE'
- ASSUME cs:cseg, ds:cseg, es:cseg, ss:cseg
-
- ORG 100h
-
- main PROC near
-
- xor AX,AX ; make sure running under Concurrent
- push DS
- mov DS,AX
- assume DS:int_tab
- cmp AX,ccpm_entry
- pop DS
- assume DS:cseg
- jnz its_ccpm
- mov SI,offset not_ccpm
- call display
- jmp exit
- its_ccpm:
- mov SI,offset signon
- call display
-
- push ES ; get system data segment location
- mov CL,s_sysdat
- int ccpm
- mov AX,ES
- pop ES
- mov sd_ofs,BX ; save system data offset
- mov sd_seg,AX ; save system data segment
- mov DI,offset sdat_hex+5
- call word_2_hex
- mov DI,offset sdat_hex
- mov BX,sd_seg
- call word_2_hex
-
- mov SI,offset sdat_msg
- call display
-
- push DS
- mov DS,sd_seg ; get system data segment
-
- mov SI,ES:sd_ofs ; get system data offset
- add SI,dph
- mov DI,offset dph_tbl ; get disk parameter header addresses
- mov CX,12 ;
- rep movsw
-
- mov DI,offset dpb_tbl ; get disk parameter block addresses
- mov BP,dpb
- call get_dph_fld
-
- mov DI,offset dirbcb_tbl ; get dir buffer ctl block addresses
- mov BP,dirbcb
- call get_dph_fld
-
- mov DI,offset datbcb_tbl ; get data buffer ctl block addresses
- mov BP,datbcb
- call get_dph_fld
-
- mov SI,offset dirbcb_tbl ; get max directory buffers per process
- mov DI,offset dirmbp_tbl
- call get_mbcbp
-
- mov SI,offset datbcb_tbl ; get max data buffers per process
- mov DI,offset datmbp_tbl
- call get_mbcbp
-
- mov SI,offset dirbcb_tbl ; get directory bcb hi, lo, and count
- mov DI,offset dirbcbhi_tbl
- call trace_bcblr
-
- mov SI,offset datbcb_tbl ; get data bcb hi, lo, and count
- mov DI,offset datbcbhi_tbl
- call trace_bcblr
-
- pop DS
-
- mov CX,12
- xor SI,SI
- mov BP,SI
- hex_lp:
- push CX
- mov BX,dph_tbl[SI] ; convert dph to hex
- lea DI,dph_hex[BP]
- call word_2_hex
- mov BX,dpb_tbl[SI] ; convert dpb to hex
- lea DI,dpb_hex[BP]
- call word_2_hex
- mov BX,dirbcb_tbl[SI] ; convert dirbcb to hex
- lea DI,dirbcb_hex[BP]
- call word_2_hex
- mov BX,dirbcbhi_tbl[SI] ; convert dir bcb hi to hex
- lea DI,dirbcbhi_hex[BP]
- call word_2_hex
- mov BX,dirbcblo_tbl[SI] ; convert dir bcb lo to hex
- lea DI,dirbcblo_hex[BP]
- call word_2_hex
- mov BX,dirbufadhi_tbl[SI] ; convert dir bufad hi to hex
- lea DI,dirbufadhi_hex[BP]
- call word_2_hex
- mov BX,dirbufadlo_tbl[SI] ; convert dir bufad lo to hex
- lea DI,dirbufadlo_hex[BP]
- call word_2_hex
- mov BX,datbcb_tbl[SI] ; convert datbcb to hex
- lea DI,datbcb_hex[BP]
- call word_2_hex
- mov BX,datbcbhi_tbl[SI] ; convert dat bcb hi to hex
- lea DI,datbcbhi_hex[BP]
- call word_2_hex
- mov BX,datbcblo_tbl[SI] ; convert dat bcb lo to hex
- lea DI,datbcblo_hex[BP]
- call word_2_hex
- mov BX,datbufadhi_tbl[SI] ; convert dat bufad hi to hex
- lea DI,datbufadhi_hex[BP]
- call word_2_hex
- mov BX,datbufadlo_tbl[SI] ; convert dat bufad lo to hex
- lea DI,datbufadlo_hex[BP]
- call word_2_hex
-
- shr SI,1
- mov AL,dirmbp_tbl[SI] ; convert dir mbcbp to hex
- lea DI,dirmbp_hex[BP]
- call byte_2_hex
- mov AL,dirbcbt_tbl[SI] ; convert dir bcb totals to hex
- lea DI,dirbcbt_hex[BP]
- call byte_2_hex
- mov AL,datmbp_tbl[SI] ; convert dat mbcbp to hex
- lea DI,datmbp_hex[BP]
- call byte_2_hex
- mov AL,datbcbt_tbl[SI] ; convert dat bcb totals to hex
- lea DI,datbcbt_hex[BP]
- call byte_2_hex
- shl SI,1
-
- add SI,2
- add BP,5
- pop CX
- dec CX
- jz display_info
- jmp hex_lp
-
- display_info:
- mov SI,offset disk_info
- call display
-
- exit:
- mov AH,4Ch
- int dos
-
- ; data area
- ;
- signon dw signon_len
- db 'Concurrent PC-DOS disk buffers and control blocks, '
- db 'Howard Vigorita',cr,lf,lf
- signon_len equ $-signon-2
-
- sdat_msg dw sdat_msg_len
- db 9,9,'System data segment located at '
- sdat_hex db 'XXXX:XXXX',cr,lf
- sdat_msg_len equ $-sdat_msg-2
-
- disk_info dw disk_info_len
- db ' A: B: C: D: E: F: G: H: I: K: L: M:'
- db cr,lf,lf,'dph '
- dph_hex db 12 dup ('XXXX ')
- db cr,lf, 'dpb '
- dpb_hex db 12 dup ('XXXX ')
-
- db cr,lf, ' dir:'
- db cr,lf, 'bcb header '
- dirbcb_hex db 12 dup ('XXXX ')
- db cr,lf, ' max/proc '
- dirmbp_hex db 12 dup ('XX ')
- db cr,lf, ' tot buffs '
- dirbcbt_hex db 12 dup ('XX ')
- db cr,lf, ' bcb hi '
- dirbcbhi_hex db 12 dup ('XXXX ')
- db cr,lf, ' bcb lo '
- dirbcblo_hex db 12 dup ('XXXX ')
- db cr,lf, ' bufadd hi '
- dirbufadhi_hex db 12 dup ('XXXX ')
- db cr,lf, ' bufadd lo '
- dirbufadlo_hex db 12 dup ('XXXX ')
-
- db cr,lf, ' data:'
- db cr,lf, 'bcb header '
- datbcb_hex db 12 dup ('XXXX ')
- db cr,lf, ' max/proc '
- datmbp_hex db 12 dup ('XX ')
- db cr,lf, ' tot buffs '
- datbcbt_hex db 12 dup ('XX ')
- db cr,lf, ' bcb hi '
- datbcbhi_hex db 12 dup ('XXXX ')
- db cr,lf, ' bcb lo '
- datbcblo_hex db 12 dup ('XXXX ')
- db cr,lf, ' bufseg hi '
- datbufadhi_hex db 12 dup ('XXXX ')
- db cr,lf, ' bufseg lo '
- datbufadlo_hex db 12 dup ('XXXX ')
- disk_info_len equ $-disk_info-2
-
- not_ccpm dw not_ccpm_len
- db 'Concurrent PC-DOS is required'
- not_ccpm_len equ $-not_ccpm-2
-
- sd_ofs dw ?
- sd_seg dw ?
- lo_addr dw ?
- hi_addr dw ?
-
- dph_tbl dw 12 dup (?) ; pointers to dph's for drives A - M
- dpb_tbl dw 12 dup (?) ; pointers to dpb's for drives A - M
- dirbcb_tbl dw 12 dup (?)
- dirmbp_tbl db 12 dup (?)
- datbcb_tbl dw 12 dup (?)
- datmbp_tbl db 12 dup (?)
-
- dirbcbhi_tbl dw 12 dup (?)
- dirbufadhi_tbl dw 12 dup (?)
- dirbcblo_tbl dw 12 dup (?)
- dirbufadlo_tbl dw 12 dup (?)
- dirbcbt_tbl db 12 dup (?)
-
- datbcbhi_tbl dw 12 dup (?)
- datbufadhi_tbl dw 12 dup (?)
- datbcblo_tbl dw 12 dup (?)
- datbufadlo_tbl dw 12 dup (?)
- datbcbt_tbl db 12 dup (?)
-
- main ENDP
-
- ; subroutines
- ;
-
- ; get buffer control block list root (word) from bcbh table
- ; (pointed to by SI) and traces through the list, recording
- ; hi & low addresses and counts in tables pointed to by DI
- ; for drives A to M
- ;
- trace_bcblr:
- mov CX,12 ; 12 drives, A to M
- trace_bcblr_lp:
- xor DX,DX ; clear hi
- mov ES:hi_addr,DX
- mov BP,DX ; clear lo
- mov ES:lo_addr,DX
- mov AX,DX ; buffer counter
- mov BX,ES:[SI] ; get bcbh pointer
- add SI,2
- or BX,BX
- jz sav_tots ; skip if null (drive not implemented)
- mov BX,[BX] ; get bcb list root
- or BX,BX
- jz sav_tots ; skip if null
- dec BP
- dec ES:lo_addr
-
- traverse:
- inc AL ; increment buffer counter
- cmp DX,link[BX] ; see if link new hi
- ja ck_hi_addr
- mov DX,link[BX] ; if so, record it
- ck_hi_addr:
- push DX
- mov DX,ES:hi_addr
- cmp DX,bufad[BX] ; see if buffer is hi
- ja ck_lo_addr
- mov DX,bufad[BX] ; if so, record it
- mov ES:hi_addr,DX
- ck_lo_addr:
- mov DX,ES:lo_addr
- cmp DX,bufad[BX] ; see if buffer is lo
- jb ck_lo
- mov DX,bufad[BX] ; if so, record it
- mov ES:lo_addr,DX
- ck_lo:
- pop DX
- cmp wpt link[BX],0
- lahf
- jz sav_tots
- cmp BP,link[BX] ; see if new lo
- jb ck_tail
- mov BP,link[BX] ; if so, record it
- ck_tail:
- mov BX,link[BX] ; get the link
- sahf ; see if end
- jnz traverse ; if not, do it again
-
- sav_tots:
- mov BX,12
- sub BX,CX ; calculate table offset
- mov ES:96[BX+DI],AL ; save count
- shl BX,1 ; double offset for word tables
- mov ES:[DI+BX],DX ; save hi bcb address
- mov DX,ES:hi_addr ; save hi buffer address
- mov ES:24[DI+BX],DX
- mov ES:48[DI+BX],BP ; save lo bcb address
- mov BP,ES:lo_addr ; save lo buffer address
- mov ES:72[DI+BX],BP
- dec CX
- jz trace_x
- jmp trace_bcblr_lp
- trace_x:
- ret
-
- ; gets maximum buffer control blocks per process (byte) from bcbh
- ; table (pointed to by SI) and put into a table pointed to by DI
- ; for drives A to M
- ;
- get_mbcbp:
- mov CX,12 ; 12 drives, A to M
- get_mbcbp_lp:
- mov AX,ES:[SI] ; get bcbh pointer
- add SI,2
- or AX,AX
- jz no_mbcbp ; skip if null (drive not implemented)
- mov BX,AX
- mov AL,mbcbp[BX]
- no_mbcbp:
- stosb
- loop get_mbcbp_lp
- ret
-
- ; gets dph field (specified by offset in BP) and puts
- ; into a table pointed to by DI for drives A to M
- ;
- get_dph_fld:
- mov SI,ES:sd_ofs ; get system data offset
- add SI,dph ; sysdat dph table
- mov CX,12 ; 12 drives, A to M
- get_dpb:
- lodsw ; get dph pointer
- or AX,AX
- jz no_dpb ; skip if null (drive not implemented)
- mov BX,AX ; move to index register
- add BX,BP
- mov AX,[BX] ; get dpb ptr from dph
- no_dpb:
- stosw ; put into local table
- loop get_dpb
- ret
-
- ; convert binary word in BX to ascii-hex and put in
- ; buffer pointed to by DI
- word_2_hex:
- mov AL,BH
- call byte_2_hex
- mov AL,BL
- call byte_2_hex
- ret
-
- ; convert binary byte in AL to ascii-hex and put in
- ; buffer pointed to by DI
- byte_2_hex:
- push AX
- call nib_2_hex
- pop AX
- mov CL,4
- shl AL,CL
- call nib_2_hex
- ret
-
- ; convert binary high order nibble in AL to ascii-hex and put in
- ; buffer pointed to by DI
- nib_2_hex:
- mov CL,4
- shr AL,CL
- cmp AL,9
- ja over_9
- add AL,'0'
- stosb
- ret
- over_9:
- add AL,'A'-10
- stosb
- ret
-
- display:
- lodsw
- mov CX,AX
- mov DX,SI
- mov BX,std_out
- mov AH,wrt_dev
- int dos
- ret
-
- cseg ENDS
- END main
-